package run.halo.app.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import run.halo.app.service.PostService;

@EnableScheduling
@Component
@Slf4j
public class ScheduledTask {

    @Autowired
    PostService postService;

    /**
     * 定时任务,每日0点清理回收站
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void clearGarbage() {
        Integer rows = postService.clearGarbage();
        log.info("定时任务, 清理回收站中超过30天的文章, rows: {}", rows);
    }
}
